/*
 * @Author: FMC
 * @Date: 2024-07-08 19:58:03
 * @LastEditors: FMC
 * @LastEditTime: 2024-07-11 00:00:04
 * @FilePath: \three-run-game\src\views\react-three\meshes\level\level.jsx
 * @Description:
 */
/**
 *
 *  关卡
 */
// import { RigidBody } from "@react-three/rapier";
// import Ground from "../gound/ground.jsx";
import BlockStart from "../block-start/block-start.jsx";
import BlockSpiner from "../block-spiner/block-spiner.jsx";
import BlockLimbo from "../block-limbo/block-limbo.jsx";
import BlockAxe from "../block-axe/block-axe.jsx";
import BlockEnd from "../block-end/block-end.jsx";
import { useMemo } from "react";
import Bounds from "../bounds/bounds.jsx";
function Level({ count = 5, types = [BlockSpiner, BlockLimbo, BlockAxe],seed=0 }) {
  const blocks = useMemo(() => {
    const blocks = [];
    for (let i = 0; i < count; i++) {
      const type = types[Math.floor(Math.random() * types.length)];
      blocks.push({
        key: i,
        Block: type,
      });
    }
    return blocks;
  }, [types, count,seed]);

  return (
    <>
      <BlockStart />
      {blocks.map((item, index) => (
        <item.Block
          position={[0, 0, -4 * (index + 1)]}
          key={item.key}
        ></item.Block>
      ))}
      <BlockEnd  BlockStart position={[0, 0, -(count + 1) * 4]} />
      <Bounds length={count+2}/>

      {/* <Ground /> */}
    </>
  );
}
export default Level;
